class AddIsSearchChunkToTimespans < ActiveRecord::Migration
  def self.up
    add_column :timespans, :is_search_chunk, :boolean
    
    # Add some initial search chunk timespans
    d = CONF.chunk_start_time
    while d < Time.now do
      Timespan.create(:after_date => d, :before_date => d + CONF.chunk_size, :is_search_chunk => true)
      d += 5.minutes
    end
  end

  def self.down
    execute("delete from timespans where is_search_chunk=1")
    remove_column :timespans, :is_search_chunk
  end
end
